
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;

namespace StudentVideo.Data.Entities;

/// <summary>
/// 用户 - 角色 映射表
/// </summary>
[Table("user_role_map")]
[Index(nameof(UserId))]
[Index(nameof(RoleId))]
[PrimaryKey(nameof(UserId), nameof(RoleId))]
public class UserRoleMapEntity {

   /// <summary>
   /// 用户 id
   /// </summary>
   [MaxLength(50)]
   public required string UserId { get; set; }

   [ForeignKey(nameof(UserId))]
   public required UserEntity User { get; set; }

   /// <summary>
   /// 角色 id
   /// </summary>
   [MaxLength(50)]
   public required string RoleId { get; set; }

   [ForeignKey(nameof(RoleId))]
   public required RoleEntity Role { get; set; }
}
